package yawning.mew.cat;

import yawning.mew.sim.SimulationEvent;

public class EventEnergyTick extends SimulationEvent {
	CatModelSimState mState;
	int mEnergy;
	int mEnergyCap;
	
	EventEnergyTick(CatModelSimState state, int startEnergy, int energyCap) {
		super(state.mSimUtil);
		mState = state;
		mEnergy = startEnergy;
		mEnergyCap = energyCap;
		schedule(0.0);
	}

	@Override
	public void onExpire() {
		schedule(Double.MAX_VALUE, mState.mModel.getEnergyTickInterval());
	}

	@Override
	public void onTick() {
		mEnergy = Math.min(mEnergyCap, mEnergy + 1);

//		if (mDebug) DBGF("Energy (%d) next tick + %f", energy, energyTickInterval);

		setTickInterval(mState.mModel.getEnergyTickInterval());
	}
}